

#ifndef WxRenderToContourCutter_H
#define WxRenderToContourCutter_H

#include "mitkCommon.h"
#include "WxExtentionExports.h"
#include <mitkImageToImageFilter.h>
#include <mitkContour.h>
#include <mitkImageTimeSelector.h>
#include <itkImage.h>
#include <vtkRenderer.h>


namespace mitk {


class WxExtention_EXPORT WxRenderToContourCutter : public ImageToImageFilter
{
public:
  mitkClassMacro(WxRenderToContourCutter, ImageToImageFilter);
  itkNewMacro(Self);

  void SetOverlayContour( const mitk::Contour* overlayContour );
  const mitk::Contour* GetOverlayContour() const;

  itkSetMacro(InsideValue,  ScalarType);
  itkGetMacro(InsideValue,  ScalarType);
  itkSetMacro(OutsideValue, ScalarType);
  itkGetMacro(OutsideValue, ScalarType);
  itkSetMacro(FillInside, bool);
  itkGetMacro(FillInside, bool);
  itkBooleanMacro(FillInside);

  void SetRenderer(vtkRenderer* renderer) {m_Renderer=renderer; this->Modified();}
  vtkRenderer* GetRenderer(){return m_Renderer;}

  itkGetMacro(InsidePixelCount, unsigned int);
  itkGetMacro(OutsidePixelCount, unsigned int);

protected:
  WxRenderToContourCutter();
  virtual ~WxRenderToContourCutter();

  virtual const std::type_info& GetOutputPixelType();

  virtual void GenerateInputRequestedRegion();
  virtual void GenerateOutputInformation();
  virtual void GenerateData();

  template < typename TPixel, unsigned int VImageDimension, typename TOutputPixel > 
    friend void CutImageWithOutputTypeSelect( itk::Image< TPixel, VImageDimension >* inputItkImage, mitk::WxRenderToContourCutter* cutter, int boTimeStep=0, TOutputPixel* dummy=NULL );
  template < typename TPixel, unsigned int VImageDimension > 
    friend void CutImage( itk::Image< TPixel, VImageDimension >* itkImage, mitk::WxRenderToContourCutter* cutter, int boTimeStep );
  virtual void ComputeData(mitk::Image* input3D, int boTimeStep);

  //##Description 
  //## @brief OverlayContour that will be cut
  mitk::Contour::Pointer m_OverlayContour;
  //##Description 
  //## @brief Value for inside pixels, used when m_FillInside is @a true
  //##
  //## \sa m_FillInside
  ScalarType m_InsideValue;
  //##Description 
  //## @brief Value for outside pixels (default: 0)
  //##
  //## Used only if m_AutoOutsideValue is \a false.
  ScalarType m_OutsideValue;

  //##Description 
  //## @brief Use m_InsideValue for inside pixels (default: \a false)
  //##
  //## If @a true, pixels that are inside m_BoundingObject
  //## will get m_InsideValue in the cutting process
  //## If @a false, they keep their original value.
  //## \sa m_InsideValue
  bool m_FillInside;

  unsigned int m_OutsidePixelCount;
  unsigned int m_InsidePixelCount;

  //##Description 
  //## @brief Region of input needed for cutting
  mitk::SlicedData::RegionType m_InputRequestedRegion;

  //##Description 
  //## @brief Time when Header was last initialized
  itk::TimeStamp m_TimeOfHeaderInitialization;

  mitk::ImageTimeSelector::Pointer m_InputTimeSelector;
  mitk::ImageTimeSelector::Pointer m_OutputTimeSelector;

  vtkRenderer* m_Renderer;

};
} // namespace mitk

#endif /* WxRenderToContourCutter_H */



